<?php

use Illuminate\Support\Facades\Route;


// 不登录也可以进入
Route::group(
    ['middleware' => 'guest:customer'],
    function () {
        Route::post('login', 'AuthController@login');
        Route::put('refresh', 'AuthController@refresh');
    }
);

// 登录才可以进入
Route::group(
    ['middleware' => 'auth:customer'],
    function () {
        Route::delete('logout', 'AuthController@logout');
        Route::get('profile/logs', 'AuthController@logs');
        Route::get('profile', 'AuthController@profile');
        Route::put('profile/password', 'AuthController@password');
    }
);


// 要验证权限
Route::group(
    ['middleware' => ['rbac:customer', 'auth:customer'], 'prefix' => 'authorities'],
    function () {
        Route::get('menu/authority', 'Authorities\MenuController@authority')->name('role.menu_authority');

        Route::get('role', 'Authorities\RoleController@index')->name('role.index');
        Route::get('role/{id}/edit', 'Authorities\RoleController@edit')->name('role.update');
        Route::get('role/create', 'Authorities\RoleController@create')->name('role.store');
        Route::post('role', 'Authorities\RoleController@store')->name('role.store');
        Route::put('role/{id}', 'Authorities\RoleController@update')->name('role.update');
        Route::delete('role/{id}', 'Authorities\RoleController@destroy')->name('role.destroy');


        Route::put('user/{user}/status', 'Authorities\UserController@status')->name('user.update');

        Route::get('user', 'Authorities\UserController@index')->name('user.index');
        Route::get('user/create', 'Authorities\UserController@create')->name('user.store');
        Route::get('user/{id}/edit', 'Authorities\UserController@edit')->name('user.update');
        Route::post('user', 'Authorities\UserController@store')->name('user.store');
        Route::put('user/{id}', 'Authorities\UserController@update')->name('user.update');

        Route::get('menu', 'Authorities\MenuController@index')->name('menu.index');
        Route::get('menu/create', 'Authorities\MenuController@create')->name('menu.store');
        Route::get('menu/{id}/edit', 'Authorities\MenuController@edit')->name('menu.update');
        Route::post('menu', 'Authorities\MenuController@store')->name('menu.store');
        Route::put('menu/{id}', 'Authorities\MenuController@update')->name('menu.update');
        Route::delete('menu/{id}', 'Authorities\MenuController@destroy')->name('menu.destroy');

        Route::get('authority', 'Authorities\AuthorityController@index')->name('authority.index');
        Route::get('authority/{id}/edit', 'Authorities\AuthorityController@edit')->name('authority.update');
        Route::post('authority', 'Authorities\AuthorityController@store')->name('authority.store');
        Route::put('authority/{id}', 'Authorities\AuthorityController@update')->name('authority.update');
        Route::delete('authority/{id}', 'Authorities\AuthorityController@destroy')->name('authority.destroy');

    }
);
